Support to build python module with pybuild
authorKentaro Hayashi <kenhys@xdump.org>
Sat, 1 Aug 2026 12:47:10 +0000 (21:47 +0900)
committerKentaro Hayashi <kenhys@xdump.org>
Sat, 1 Aug 2026 11:20:13 +0000 (20:20 +0900)
Description: Support to build python module with pybuild
Forwarded: not-needed
Last-Update: 2026-08-01

Gbp-Pq: Name support-building-python-module.patch

python/setup.py

index 60e0811bdc50827b4ced71645a311a0ab6345c36..078a2587a9ae2d21c190b20ae0613a22aafc2bec 100755 (executable)
@@ -69,6 +69,18 @@ def get_protobuf_includes():
 
 
 def get_cflags_and_libs(root):
+  if os.environ.get('USE_SHARED_SENTENCEPIECE') == '1':
+    include_dirs = os.environ['SENTENCEPIECE_INCLUDE_DIR']
+    library_dir = os.environ['SENTENCEPIECE_LIBRARY_DIR']
+    cflags = ['-std=c++17']
+    for include_dir in include_dirs.split(os.pathsep):
+      if include_dir:
+        cflags.append('-I' + os.path.normpath(include_dir))
+    return cflags, [
+      '-L' + os.path.normpath(library_dir),
+      '-lsentencepiece',
+      '-lsentencepiece_train',
+    ]
   cflags = [
       '-std=c++17',
       '-I' + os.path.normpath(os.path.join(root, 'include')),